package com.basic.business.memoRelation.controller;


import java.util.List;
import java.io.IOException;
import org.springframework.security.access.prepost.PreAuthorize;
import javax.annotation.Resource;
import com.basic.common.annotation.FileExport;
import com.basic.common.utils.easyExcel.EasyExcelUtils;
import org.springframework.web.bind.annotation.*;
import com.basic.common.annotation.Log;
import com.basic.common.core.controller.BaseController;
import com.basic.common.core.domain.AjaxResult;
import com.basic.common.enums.BusinessType;
import com.basic.business.memoRelation.domain.TOrdersMemoRelation;
import com.basic.business.memoRelation.service.ITOrdersMemoRelationService;
import com.basic.common.core.page.TableDataInfo;

/**
 * 备注关系Controller
 * 
 * @author zhaoxy_jn@163.com
 */
@RestController
@RequestMapping("/business/memoRelation")
public class TOrdersMemoRelationController extends BaseController
{
    @Resource
    private ITOrdersMemoRelationService tOrdersMemoService;

    /**
     * 查询备注关系列表
     */
    @PreAuthorize("@ss.hasPermi('business:memoRelation:list')")
    @GetMapping("/list")
    public TableDataInfo list(TOrdersMemoRelation tOrdersMemoRelation)
    {
        startPage();
        List<TOrdersMemoRelation> list = tOrdersMemoService.getList(tOrdersMemoRelation);
        return getDataTable(list);
    }

    /**
     * 导出备注关系列表
     */
    @PreAuthorize("@ss.hasPermi('business:memoRelation:export')")
    @Log(title = "备注关系", businessType = BusinessType.EXPORT)
    @FileExport(fileName = "备注关系.xlsx")
    @PostMapping("/export")
    public String export(TOrdersMemoRelation tOrdersMemoRelation) throws IOException
    {
        List<TOrdersMemoRelation> list = tOrdersMemoService.getList(tOrdersMemoRelation);
        return EasyExcelUtils.excelExport(TOrdersMemoRelation.class,"备注关系数据", list);
    }

    /**
     * 获取备注关系详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:memoRelation:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(tOrdersMemoService.get(id));
    }

    /**
     * 新增备注关系
     */
    @PreAuthorize("@ss.hasPermi('business:memoRelation:add')")
    @Log(title = "备注关系", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TOrdersMemoRelation tOrdersMemoRelation)
    {
        return toAjax(tOrdersMemoService.insert(tOrdersMemoRelation));
    }

    /**
     * 修改备注关系
     */
    @PreAuthorize("@ss.hasPermi('business:memoRelation:edit')")
    @Log(title = "备注关系", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TOrdersMemoRelation tOrdersMemoRelation)
    {
        return toAjax(tOrdersMemoService.update(tOrdersMemoRelation));
    }

    /**
     * 删除备注关系
     */
    @PreAuthorize("@ss.hasPermi('business:memoRelation:remove')")
    @Log(title = "备注关系", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(tOrdersMemoService.deleteByIds(ids));
    }

    /**
     * 状态变更
     */
    @PreAuthorize("@ss.hasPermi('business:memoRelation:changeStatus')")
    @Log(title = "备注关系", businessType = BusinessType.UPDATE)
    @PutMapping("/changeStatus")
    public AjaxResult changeMountStatus(@RequestParam("ids") String[] ids, @RequestParam("status") String status)
    {
        return toAjax(tOrdersMemoService.updateStatusByIds(ids, status));
    }

    /**
     * 刷新缓存
     */
    @PreAuthorize("@ss.hasPermi('business:memoRelation:refreshCache')")
    @Log(title = "备注关系", businessType = BusinessType.CLEAN)
    @DeleteMapping("/refreshCache")
    public AjaxResult refreshCache()
    {
        tOrdersMemoService.resetMemoRelationCache();
        return success();
    }
}
